package com.bytedance.common.b;

import android.annotation.TargetApi;
import android.os.Build;
import android.webkit.CookieManager;
import android.webkit.WebSettings;
import android.webkit.WebView;

public final class MixedContentCookieCompat {
    static class IMPL {
        private IMPL() {

        }

        public void setMixedContentMode(WebSettings webSettings) {
        }

        public void setAcceptThirdPartyCookies(WebView webView) {
        }
    }

    @TargetApi(value=21)
    static final class IMPL21 extends IMPL {

        private IMPL21() {
            super();
        }

        public final void setMixedContentMode(WebSettings webSettings) {
            if(webSettings != null) {
                try {
                    webSettings.setMixedContentMode(0);
                }
                catch(Exception v0) {
                }
            }
        }

        public final void setAcceptThirdPartyCookies(WebView webView) {
            if(webView != null) {
                try {
                    CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
                }
                catch(Exception v0) {
                }
            }
        }
    }

    private static IMPL IMPL = Build.VERSION.SDK_INT >= 21 ? new IMPL21() : new IMPL();

    public static void setMixedContentMode(WebSettings webSettings) {
        MixedContentCookieCompat.IMPL.setMixedContentMode(webSettings);
    }

    public static void setAcceptThirdPartyCookies(WebView webView) {
        MixedContentCookieCompat.IMPL.setAcceptThirdPartyCookies(webView);
    }
}

